﻿///////////////////////////////////////////////////////////////
// This is generated code. 
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: 3.5
// Code is generated on: Monday, December 17, 2012 11:21:26 AM
// Code is generated using templates: SD.TemplateBindings.SharedTemplates.NET20
// Templates vendor: Solutions Design.
// Templates version: 
//////////////////////////////////////////////////////////////
using System;
using System.Collections;
using System.Collections.Generic;
using WHMS;
using WHMS.FactoryClasses;
using WHMS.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;

namespace WHMS.RelationClasses
{
	/// <summary>Implements the relations factory for the entity: Item. </summary>
	public partial class ItemRelations
	{
		/// <summary>CTor</summary>
		public ItemRelations()
		{
		}

		/// <summary>Gets all relations of the ItemEntity as a list of IEntityRelation objects.</summary>
		/// <returns>a list of IEntityRelation objects</returns>
		public virtual List<IEntityRelation> GetAllRelations()
		{
			List<IEntityRelation> toReturn = new List<IEntityRelation>();
			toReturn.Add(this.InitialBalanceEntityUsingItemId);
			toReturn.Add(this.InventoryItemEntityUsingItemId);
			toReturn.Add(this.ItemSupplierEntityUsingItemId);
			toReturn.Add(this.ProjectItemPlanEntityUsingItemId);
			toReturn.Add(this.StoreShelfBalanceEntityUsingItemId);
			toReturn.Add(this.SupplyOrderItemEntityUsingItemId);
			toReturn.Add(this.TransactionItemEntityUsingItemId);
			toReturn.Add(this.TransferRequestItemEntityUsingItemId);
			toReturn.Add(this.WithdrawRequestItemEntityUsingItemId);
			toReturn.Add(this.ItemTypeEntityUsingTypeId);
			toReturn.Add(this.UnitEntityUsingUnitId);
			toReturn.Add(this.UnitTypeEntityUsingUnitTypeId);
			return toReturn;
		}

		#region Class Property Declarations

		/// <summary>Returns a new IEntityRelation object, between ItemEntity and InitialBalanceEntity over the 1:n relation they have, using the relation between the fields:
		/// Item.Id - InitialBalance.ItemId
		/// </summary>
		public virtual IEntityRelation InitialBalanceEntityUsingItemId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "InitialBalances" , true);
				relation.AddEntityFieldPair(ItemFields.Id, InitialBalanceFields.ItemId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ItemEntity", true);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("InitialBalanceEntity", false);
				return relation;
			}
		}

		/// <summary>Returns a new IEntityRelation object, between ItemEntity and InventoryItemEntity over the 1:n relation they have, using the relation between the fields:
		/// Item.Id - InventoryItem.ItemId
		/// </summary>
		public virtual IEntityRelation InventoryItemEntityUsingItemId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "InventoryItems" , true);
				relation.AddEntityFieldPair(ItemFields.Id, InventoryItemFields.ItemId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ItemEntity", true);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("InventoryItemEntity", false);
				return relation;
			}
		}

		/// <summary>Returns a new IEntityRelation object, between ItemEntity and ItemSupplierEntity over the 1:n relation they have, using the relation between the fields:
		/// Item.Id - ItemSupplier.ItemId
		/// </summary>
		public virtual IEntityRelation ItemSupplierEntityUsingItemId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "ItemSuppliers" , true);
				relation.AddEntityFieldPair(ItemFields.Id, ItemSupplierFields.ItemId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ItemEntity", true);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ItemSupplierEntity", false);
				return relation;
			}
		}

		/// <summary>Returns a new IEntityRelation object, between ItemEntity and ProjectItemPlanEntity over the 1:n relation they have, using the relation between the fields:
		/// Item.Id - ProjectItemPlan.ItemId
		/// </summary>
		public virtual IEntityRelation ProjectItemPlanEntityUsingItemId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "ProjectItemPlans" , true);
				relation.AddEntityFieldPair(ItemFields.Id, ProjectItemPlanFields.ItemId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ItemEntity", true);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ProjectItemPlanEntity", false);
				return relation;
			}
		}

		/// <summary>Returns a new IEntityRelation object, between ItemEntity and StoreShelfBalanceEntity over the 1:n relation they have, using the relation between the fields:
		/// Item.Id - StoreShelfBalance.ItemId
		/// </summary>
		public virtual IEntityRelation StoreShelfBalanceEntityUsingItemId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "StoreShelfBalances" , true);
				relation.AddEntityFieldPair(ItemFields.Id, StoreShelfBalanceFields.ItemId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ItemEntity", true);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("StoreShelfBalanceEntity", false);
				return relation;
			}
		}

		/// <summary>Returns a new IEntityRelation object, between ItemEntity and SupplyOrderItemEntity over the 1:n relation they have, using the relation between the fields:
		/// Item.Id - SupplyOrderItem.ItemId
		/// </summary>
		public virtual IEntityRelation SupplyOrderItemEntityUsingItemId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "SupplyOrderItems" , true);
				relation.AddEntityFieldPair(ItemFields.Id, SupplyOrderItemFields.ItemId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ItemEntity", true);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("SupplyOrderItemEntity", false);
				return relation;
			}
		}

		/// <summary>Returns a new IEntityRelation object, between ItemEntity and TransactionItemEntity over the 1:n relation they have, using the relation between the fields:
		/// Item.Id - TransactionItem.ItemId
		/// </summary>
		public virtual IEntityRelation TransactionItemEntityUsingItemId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "TransactionItems" , true);
				relation.AddEntityFieldPair(ItemFields.Id, TransactionItemFields.ItemId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ItemEntity", true);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("TransactionItemEntity", false);
				return relation;
			}
		}

		/// <summary>Returns a new IEntityRelation object, between ItemEntity and TransferRequestItemEntity over the 1:n relation they have, using the relation between the fields:
		/// Item.Id - TransferRequestItem.ItemId
		/// </summary>
		public virtual IEntityRelation TransferRequestItemEntityUsingItemId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "TransferRequestItems" , true);
				relation.AddEntityFieldPair(ItemFields.Id, TransferRequestItemFields.ItemId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ItemEntity", true);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("TransferRequestItemEntity", false);
				return relation;
			}
		}

		/// <summary>Returns a new IEntityRelation object, between ItemEntity and WithdrawRequestItemEntity over the 1:n relation they have, using the relation between the fields:
		/// Item.Id - WithdrawRequestItem.ItemId
		/// </summary>
		public virtual IEntityRelation WithdrawRequestItemEntityUsingItemId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "WithdrawRequestItems" , true);
				relation.AddEntityFieldPair(ItemFields.Id, WithdrawRequestItemFields.ItemId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ItemEntity", true);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("WithdrawRequestItemEntity", false);
				return relation;
			}
		}


		/// <summary>Returns a new IEntityRelation object, between ItemEntity and ItemTypeEntity over the m:1 relation they have, using the relation between the fields:
		/// Item.TypeId - ItemType.Id
		/// </summary>
		public virtual IEntityRelation ItemTypeEntityUsingTypeId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne, "ItemType", false);
				relation.AddEntityFieldPair(ItemTypeFields.Id, ItemFields.TypeId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ItemTypeEntity", false);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ItemEntity", true);
				return relation;
			}
		}
		/// <summary>Returns a new IEntityRelation object, between ItemEntity and UnitEntity over the m:1 relation they have, using the relation between the fields:
		/// Item.UnitId - Unit.Id
		/// </summary>
		public virtual IEntityRelation UnitEntityUsingUnitId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne, "Unit_", false);
				relation.AddEntityFieldPair(UnitFields.Id, ItemFields.UnitId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("UnitEntity", false);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ItemEntity", true);
				return relation;
			}
		}
		/// <summary>Returns a new IEntityRelation object, between ItemEntity and UnitTypeEntity over the m:1 relation they have, using the relation between the fields:
		/// Item.UnitTypeId - UnitType.Id
		/// </summary>
		public virtual IEntityRelation UnitTypeEntityUsingUnitTypeId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne, "UnitType_", false);
				relation.AddEntityFieldPair(UnitTypeFields.Id, ItemFields.UnitTypeId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("UnitTypeEntity", false);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ItemEntity", true);
				return relation;
			}
		}
		/// <summary>stub, not used in this entity, only for TargetPerEntity entities.</summary>
		public virtual IEntityRelation GetSubTypeRelation(string subTypeEntityName) { return null; }
		/// <summary>stub, not used in this entity, only for TargetPerEntity entities.</summary>
		public virtual IEntityRelation GetSuperTypeRelation() { return null;}
		#endregion

		#region Included Code

		#endregion
	}
	
	/// <summary>Static class which is used for providing relationship instances which are re-used internally for syncing</summary>
	internal static class StaticItemRelations
	{
		internal static readonly IEntityRelation InitialBalanceEntityUsingItemIdStatic = new ItemRelations().InitialBalanceEntityUsingItemId;
		internal static readonly IEntityRelation InventoryItemEntityUsingItemIdStatic = new ItemRelations().InventoryItemEntityUsingItemId;
		internal static readonly IEntityRelation ItemSupplierEntityUsingItemIdStatic = new ItemRelations().ItemSupplierEntityUsingItemId;
		internal static readonly IEntityRelation ProjectItemPlanEntityUsingItemIdStatic = new ItemRelations().ProjectItemPlanEntityUsingItemId;
		internal static readonly IEntityRelation StoreShelfBalanceEntityUsingItemIdStatic = new ItemRelations().StoreShelfBalanceEntityUsingItemId;
		internal static readonly IEntityRelation SupplyOrderItemEntityUsingItemIdStatic = new ItemRelations().SupplyOrderItemEntityUsingItemId;
		internal static readonly IEntityRelation TransactionItemEntityUsingItemIdStatic = new ItemRelations().TransactionItemEntityUsingItemId;
		internal static readonly IEntityRelation TransferRequestItemEntityUsingItemIdStatic = new ItemRelations().TransferRequestItemEntityUsingItemId;
		internal static readonly IEntityRelation WithdrawRequestItemEntityUsingItemIdStatic = new ItemRelations().WithdrawRequestItemEntityUsingItemId;
		internal static readonly IEntityRelation ItemTypeEntityUsingTypeIdStatic = new ItemRelations().ItemTypeEntityUsingTypeId;
		internal static readonly IEntityRelation UnitEntityUsingUnitIdStatic = new ItemRelations().UnitEntityUsingUnitId;
		internal static readonly IEntityRelation UnitTypeEntityUsingUnitTypeIdStatic = new ItemRelations().UnitTypeEntityUsingUnitTypeId;

		/// <summary>CTor</summary>
		static StaticItemRelations()
		{
		}
	}
}
